function mcoutest2

tic
 mcvar=zeros(51,1);

for ii=1:10
randseed=randn(5001,5000);
    %     for mm=1:5001
%         for nn=1:10000
%             randseed(mm,nn)=randn(1);
%         end
%     end
    samplepaths=oupath(randseed,0,1,1,1);
%     for jj=1:51
%         index=jj*100+1;
%         sum(samplepaths(1:index,:),2);
%     end
    samplepaths=samplepaths.^2;
    mcvar=mcvar+sum(samplepaths(1:100:5001,:),2);
    %mcvar=sum(samplepaths(1:100:5001,:),2);
end
mcvar=mcvar/50000;
toc
% tic
% for ii=1:100000
%     getOU=ouprocess(0,1,1,1,5001);
%     samplepaths=getOU.^2;
%     mcvar=mcvar+samplepaths(1:100:5001)';
% end
% mcvar=mcvar/100000;
% toc


a=1;b=1;m=1;yic=1;
    time=(0:50)*0.5/50;
    exactvar=b^2/2/a*(1-exp(-2*a*time))'+(m+(yic-m)*exp(-a*time)).^2';
    plot(time,mcvar,'k')
    hold on
    %plot(time,exactvar,'r')
    plot(time,time+1,'k')